<?php
require_once("../../resources/commons.php");
require_once("../../data/User.php");
require_once("../../data/Report.php");

SessionManager::getInstance()->checkSession();
displayTop("My reports",null,null);
$l_user=User::getFromPrimaryKey(SessionManager::getCurrentLoggedUserId());
$l_weeklyReport=$l_user->getLastUnvalidatedReport();
if(isset($l_weeklyReport)){
?>
<h1>Your last report</h1>
<p>
<b>Created: </b><?=$l_weeklyReport->getCreatedDate() ?>
</p>
<p>
<div style="border:1px solid;background-color: white;padding: 5px">
<?=$l_weeklyReport->getNotes() ?>
</div>
</p>
<a style="font-weight: bold;color: red;" href="publish_report.php?id=<?=base64_encode($l_weeklyReport->getId()) ?>" onclick="return confirm('Do you want to publish this report ?');">Publish this report</a>
<?php
}else{
?>
<div style="color: white;background-color: red;">Weekly report not yet edited</div>
<?php
}
?>
<p><a href="weekly_report.php">Edit you weekly report</a></p>
<br/>
<?php
displayBottom();
?>